<template>
	<view>
		<up-navbar :placeholder="true" :safeAreaInsetTop="true" :title="job.workName" @leftClick="back"></up-navbar>
		<view class="container">
			<view class="title">
				<text id="workName">{{ job.workName }}</text>
				<text id="salary">{{ job.workSalaryStart }}-{{ job.workSalaryEnd }}K</text>
			</view>
			<view class="info">
				<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="rgba(163,163,163,1)">
					<path
						d="M18.364 17.364L12 23.7279L5.63604 17.364C2.12132 13.8492 2.12132 8.15076 5.63604 4.63604C9.15076 1.12132 14.8492 1.12132 18.364 4.63604C21.8787 8.15076 21.8787 13.8492 18.364 17.364ZM12 15C14.2091 15 16 13.2091 16 11C16 8.79086 14.2091 7 12 7C9.79086 7 8 8.79086 8 11C8 13.2091 9.79086 15 12 15ZM12 13C10.8954 13 10 12.1046 10 11C10 9.89543 10.8954 9 12 9C13.1046 9 14 9.89543 14 11C14 12.1046 13.1046 13 12 13Z"
					></path>
				</svg>
				<text class="infoText">{{ job.workLocation }}</text>
				<svg style="margin-left: 20px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="rgba(163,163,163,1)">
					<path
						d="M9 13V16H15V13H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V13H9ZM11 11H13V14H11V11ZM7 5V2C7 1.44772 7.44772 1 8 1H16C16.5523 1 17 1.44772 17 2V5H21C21.5523 5 22 5.44772 22 6V11H15V9H9V11H2V6C2 5.44772 2.44772 5 3 5H7ZM9 3V5H15V3H9Z"
					></path>
				</svg>
				<text class="infoText">{{ job.workExperience }}</text>
				<svg style="margin-left: 20px" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" id="Graduation-Cap--Streamline-Core" height="24" width="24">
					<desc>Graduation Cap Streamline Icon: https://streamlinehq.com</desc>
					<g id="graduation-cap--graduation-cap-education">
						<path
							id="Union"
							fill="#a3a3a3"
							fill-rule="evenodd"
							d="M12.340765714285714 1.2485931428571428c-0.21740571428571426 -0.09419999999999999 -0.46412571428571425 -0.09419999999999999 -0.6815314285714286 0L0.5163754285714286 6.076508571428572C0.20288914285714285 6.212331428571428 0 6.521348571428572 0 6.863005714285714c0 0.34164 0.20288914285714285 0.6506571428571428 0.5163754285714286 0.7864971428571428l1.5301731428571428 0.6629828571428571V17.897142857142857c-0.7445845714285714 0.33034285714285716 -1.2639291428571426 1.0760571428571428 -1.2639291428571426 1.943142857142857 0 1.1734285714285713 0.9512605714285713 2.124685714285714 2.1247062857142853 2.124685714285714s2.124702857142857 -0.9512571428571427 2.124702857142857 -2.124685714285714c0 -0.867942857142857 -0.5203371428571428 -1.614342857142857 -1.2660685714285713 -1.9441714285714287V9.057462857142857l7.893274285714285 3.419948571428571c0.21740571428571426 0.09419999999999999 0.46412571428571425 0.09419999999999999 0.6815314285714286 0l11.142891428571428 -4.827908571428571c0.3133714285714285 -0.13584 0.5163428571428571 -0.44485714285714284 0.5163428571428571 -0.7864971428571428 0 -0.3416571428571428 -0.20297142857142858 -0.6506742857142856 -0.5163428571428571 -0.7864971428571428L12.340765714285714 1.2485931428571428ZM5.066897142857143 16.034451428571426l-0.008588571428571428 -4.081354285714286L10.806514285714284 14.443645714285712c0.7609542857142857 0.3296914285714285 1.6244399999999999 0.3296914285714285 2.3853771428571426 0L18.941142857142854 11.952651428571428l0.0008571428571428571 4.079811428571428c0 0.18733714285714284 -0.06137142857142856 0.3695142857142857 -0.17468571428571428 0.5186914285714286l-0.6824571428571429 -0.5185028571428572c0.6824571428571429 0.5185028571428572 0.6822857142857143 0.51888 0.6819428571428571 0.5192571428571429l-0.0006857142857142857 0.0008228571428571429 -0.0013714285714285714 0.001817142857142857 -0.003257142857142857 0.004285714285714286 -0.008742857142857142 0.011194285714285714 -0.026228571428571427 0.032537142857142855c-0.021257142857142856 0.026022857142857143 -0.05022857142857143 0.060565714285714285 -0.08725714285714285 0.10237714285714286 -0.07388571428571428 0.08358857142857141 -0.17965714285714285 0.19649142857142857 -0.31834285714285715 0.32869714285714285 -0.27737142857142855 0.2641885714285714 -0.6882857142857143 0.6070457142857142 -1.242 0.9468171428571428 -1.1129485714285714 0.6829714285714285 -2.787788571428571 1.344 -5.079377142857142 1.344 -2.2916742857142856 0 -3.964371428571428 -0.6610285714285714 -5.075297142857142 -1.3445142857142856 -0.552702857142857 -0.33994285714285716 -0.9624514285714285 -0.6829714285714285 -1.2389999999999999 -0.9474342857142857 -0.13834285714285713 -0.13232571428571427 -0.24373714285714285 -0.24533142857142853 -0.31736571428571425 -0.3290228571428571 -0.03684 -0.04186285714285714 -0.06579428571428571 -0.07645714285714285 -0.08701714285714285 -0.10253142857142857l-0.026057142857142855 -0.032588571428571425 -0.008725714285714285 -0.011245714285714284 -0.0033085714285714285 -0.004302857142857143 -0.0013714285714285714 -0.001817142857142857 -0.0006342857142857143 -0.0008228571428571429c-0.00029142857142857144 -0.00039428571428571426 -0.0005828571428571429 -0.0007714285714285713 0.6832114285714286 -0.5174742857142857l-0.6837942857142857 0.5167028571428571c-0.11206285714285713 -0.14831999999999998 -0.17288571428571428 -0.3290571428571429 -0.17328 -0.5149542857142857Z"
							clip-rule="evenodd"
							stroke-width="1"
						></path>
					</g>
				</svg>
				<text class="infoText">{{ job.workEducation }}</text>
				<view v-if="job.workType === '有'" style="margin-top: 10px">
					<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="rgba(163,163,163,1)">
						<path
							d="M23 18.9999H22V8.99991H18V6.58569L12 0.585693L6 6.58569V8.99991H2V18.9999H1V20.9999H23V18.9999ZM6 19H4V11H6V19ZM18 11H20V19H18V11ZM11 12H13V19H11V12Z"
						></path>
					</svg>
					<text class="infoText" style="margin-top: -100px">校企合作企业</text>
				</view>
			</view>
			<up-divider></up-divider>
			<view class="profile">
				<up-avatar :src="job.companyLogo" shape="circle" size="60" class="profile-image"></up-avatar>
				<view class="user-info">
					<text class="user-name">{{ job.juridicalPerson }} {{ job.juridicalPersonSex }}</text>
					<text class="user-position">{{ job.companyName }} · {{ job.companyScale }}</text>
					<text class="response-info">{{ job.companyContent }}</text>
				</view>
			</view>
			<up-divider />
			<text class="detail-title">职位详情</text>
			<br />
			<text class="detail-content" v-if="job.workDetails != null">{{ job.workDetails }}</text>
			<up-empty v-else mode="data" text="发布者没有填写职位详情"></up-empty>
		</view>
		<view class="like">
			<view class="like-title">
				<text class="detail-title">猜你喜欢</text>
				<u-button style="width: 60px; margin: 0" text="换一批" size="mini" icon="reload" shape="circle" @click="getLike"></u-button>
			</view>
			<view v-for="(job, index) in jobs" :key="index" class="job-card" @click="goToDetail(job.workId)">
				<view class="job-header">
					<view class="job-title">{{ job.workName }}</view>
					<view class="salary">{{ job.workSalaryStart }}-{{ job.workSalaryEnd }}K</view>
				</view>
				<view class="job-info">
					<view class="company">{{ job.companyName }}</view>
					<view class="tags">
						<view class="tag">{{ job.workEducation }}</view>
						<text class="info">{{ job.workDetails }}</text>
					</view>
					<view class="contact-location">
						<view class="contact">
							<u-avatar class="avatar" :src="job.companyLogo"></u-avatar>
							联系人　{{ job.juridicalPerson }} {{ job.juridicalPersonSex }}
						</view>
						<view class="location">{{ job.workLocation.split('-').slice(0, 3).join(' ') }}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="chat">
			<up-button type="primary" size="large" text="前往沟通"></up-button>
		</view>
		<view class="safe-area"></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			job: {},
			jobs: []
		};
	},
	onLoad(options) {
		this.getJobDetail(options.id);
	},
	methods: {
		back() {
			uni.navigateBack();
		},
		// 获取职位详情
		getJobDetail(id) {
			this.$api.getWorkDetail({ id }).then((res) => {
				this.job = res.data;
				this.getLike();
			});
		},
		getLike() {
			this.$api
				.getWork({
					positionId: -1,
					page: 1,
					pageSize: 3
				})
				.then((res) => {
					this.jobs = res.data;
				});
		}
	}
};
</script>

<style scoped>
.container {
	padding: 30rpx;
}
.title {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

#workName {
	font-size: 35rpx;
	font-weight: bold;
}
#salary {
	font-size: 30rpx;
	color: #59a0ff;
	margin-left: 20rpx;
}

.info {
	display: flex;
	align-items: center;
	margin-top: 30rpx;
	flex-wrap: wrap;
}

.infoText {
	font-size: 24rpx;
	margin-left: 10rpx;
	color: #a3a3a3;
}

.user-card {
	display: flex;
	align-items: center;
	padding: 10px;
	border-bottom: 1px solid #ddd;
}
.profile {
	display: flex;
	align-items: center;
}
.profile-image {
	width: 50px;
	height: 50px;
	border-radius: 50%;
	margin-right: 10px;
}
.user-info {
	display: flex;
	flex-direction: column;
}
.user-name {
	font-weight: bold;
	font-size: 16px;
}
.user-position {
	color: #888;
	font-size: 14px;
	margin-top: 5px;
}
.response-info {
	color: #888;
	font-size: 12px;
	margin-top: 5px;
	width: 400px;
}

.detail-title {
	font-size: 28rpx;
	font-weight: bold;
	margin-top: 30rpx;
	margin-bottom: 10rpx;
	color: #333;
}

.detail-content {
	font-size: 24rpx;
	line-height: 1.5;
	color: #666;
	margin-top: 10rpx;
	width: 400px;
	white-space: pre-wrap;
	word-wrap: break-word;
	word-break: break-all;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
}
.like {
	margin-top: 30rpx;
	padding: 20px;
}

.like-title {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.chat {
	position: fixed;
	bottom: 0;
	width: 95%;
	background-color: #fff;
	padding: 10px;
	box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

.safe-area {
	padding-bottom: calc(env(safe-area-inset-bottom) + 130px);
}
.info {
	transform: translateY(-14px);
}
.job-card {
	padding: 20rpx;
	background-color: #ffffff;
	border-radius: 12rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
	margin-bottom: 20rpx;
}

.job-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20rpx;
}

.job-title {
	font-size: 32rpx;
	font-weight: bold;
}

.salary {
	font-size: 32rpx;
	color: #e54d42;
}

.job-info {
	font-size: 24rpx;
	color: #999;
}

.company {
	margin-bottom: 10rpx;
}

.tags {
	display: flex;
	flex-wrap: wrap;
	margin-bottom: 10rpx;
	align-items: center;
}

.tag {
	background-color: #f5f5f5;
	color: #333;
	padding: 8rpx 16rpx;
	border-radius: 8rpx;
	margin-right: 10rpx;
	margin-bottom: 10rpx;
	font-size: 24rpx;
}

.contact-location {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10rpx;
}

.contact {
	display: flex;
	align-items: center;
}

.avatar {
	width: 48rpx;
	height: 48rpx;
	margin-right: 8rpx;
}

.location {
	color: #999;
}
</style>
